package com.awspaas.user.apps.shhtaerospaceindustrial.guaranteecar;


	import java.util.List;
import java.util.Map;

import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
import com.actionsoft.bpms.bpmn.engine.listener.InterruptListener;
import com.actionsoft.bpms.bpmn.engine.listener.InterruptListenerInterface;
import com.actionsoft.bpms.commons.database.ColumnMapRowMapper;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.exception.BPMNError;
import com.actionsoft.sdk.local.SDK;
import com.awspaas.user.apps.shhtaerospaceindustrial.util.CoreUtil;

	public class checkDriverIsnotWrite extends InterruptListener  implements InterruptListenerInterface{

		public String getDescription() {
			return "驾驶员完成后，检验出车、返回路码数等是否填写！";
		}
		
		public String getProvider() {
			return "Actionsoft";
		}
		
		public String getVersion() {
			return "1.0";
		}
		
		@Override
		public boolean execute(ProcessExecutionContext param) throws Exception {
			boolean flag_ok = SDK.getTaskAPI().isChoiceActionMenu(param.getTaskInstance(), "接单");
			if(flag_ok) {
				// 记录ID
				String processInstId = param.getProcessInstance().getId();
				//根据流程实例ID获取任务表内数据
				List<Map<String , Object>> list = DBSql.query("SELECT *  FROM BO_EU_GUARANTEECAR  "
						+ "WHERE BINDID = ? ", new ColumnMapRowMapper(), new Object[] {processInstId});
				Map<String , Object>  datarecord = list.get(0);
				String DEPARTURENUM =CoreUtil.objToStr(datarecord.get("DEPARTURENUM"));// 出车时路码数
				String RETURNNUM =CoreUtil.objToStr(datarecord.get("RETURNNUM"));// 返回时路码数
				String DEPARTURETIME =CoreUtil.objToStr(datarecord.get("DEPARTURETIME"));// 出车时间
				String RETURNTIME =CoreUtil.objToStr(datarecord.get("RETURNTIME"));// 返回时间
				if ("".equals(DEPARTURENUM)) {
					
					throw new BPMNError("“出车时路码数”不能为空，请填写后才能提交！");
					
				} else if("".equals(RETURNNUM)) {
					throw new BPMNError("“返回时路码数”不能为空，请填写后才能提交！");
				}else if("".equals(DEPARTURETIME)) {
					throw new BPMNError("“出车时间”不能为空，请填写后才能提交！");
				}else if("".equals(RETURNTIME)) {
					throw new BPMNError("“返回时间”不能为空，请填写后才能提交！");
				}
			}
			return true;
		}

	}
